package com.dandandog.framework.auth.config;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;

/**
 * @Author: JohnnyLiu
 * @Date: 2022/1/27 10:14
 */
@Slf4j
@Import(cn.hutool.extra.spring.SpringUtil.class)
@ComponentScan(basePackages = {"com.dandandog.framework.auth"})
public class SpringAutoScanConfig {

    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
        scannerConfigurer.setBasePackage("com.dandandog.**");
        scannerConfigurer.setAnnotationClass(Mapper.class);
        return scannerConfigurer;
    }

    @Bean
    public MybatisPlusPropertiesCustomizer typeEnumsPackageScanner() {
        return new TypeEnumsPackageScanner() {
            @Override
            protected String getTypeEnumsPackage() {
                return "com.dandandog.framework.**.enums";
            }
        };
    }


    public SpringAutoScanConfig() {
        log.debug("Common config initialization");
    }
}
